
package nccloud.bs.hrjx.bill.aggbusi.ace.bp;

import nc.impl.pubapp.pattern.data.bill.template.UpdateBPTemplate;
import nc.impl.pubapp.pattern.rule.IRule;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.vo.hrjx.jxxsdata.AggJxXsDataVO;
import nccloud.bs.hrjx.bill.aggbusi.ace.rule.BeforeUpdateRule;
import nccloud.bs.hrjx.bill.aggbusi.plugin.bpplugin.JxXsDataVOPluginPoint;

/**
 *
 */
public class AceJxXsDataVOUpdateBP {

	public AggJxXsDataVO[] update(AggJxXsDataVO[] bills, AggJxXsDataVO[] originBills) {
		UpdateBPTemplate<AggJxXsDataVO> bp = new UpdateBPTemplate<AggJxXsDataVO>(JxXsDataVOPluginPoint.UPDATE);
		this.addBeforeRule(bp.getAroundProcesser());
		this.addAfterRule(bp.getAroundProcesser());
		return bp.update(bills, originBills);
	}

	private void addAfterRule(CompareAroundProcesser<AggJxXsDataVO> processer) {
//		IRule<AggJxXsDataVO> rule = null;
//		rule = new nc.bs.pubapp.pub.rule.BillCodeCheckRule();
//		((nc.bs.pubapp.pub.rule.BillCodeCheckRule) rule).setCbilltype("ZH01");
//		((nc.bs.pubapp.pub.rule.BillCodeCheckRule) rule).setCodeItem("vbillno");
//		((nc.bs.pubapp.pub.rule.BillCodeCheckRule) rule).setGroupItem("pk_group");
//		((nc.bs.pubapp.pub.rule.BillCodeCheckRule) rule).setOrgItem("pk_org");
//		processer.addAfterRule(rule);

	}

	private void addBeforeRule(CompareAroundProcesser<AggJxXsDataVO> processer) {
		IRule<AggJxXsDataVO> rule = null;
		rule = new nc.bs.pubapp.pub.rule.FillUpdateDataRule();
		processer.addBeforeRule(rule);
		nc.impl.pubapp.pattern.rule.ICompareRule<AggJxXsDataVO> ruleCom = new nc.bs.pubapp.pub.rule.UpdateBillCodeRule();
		((nc.bs.pubapp.pub.rule.UpdateBillCodeRule) ruleCom).setCbilltype("ZH01");
		((nc.bs.pubapp.pub.rule.UpdateBillCodeRule) ruleCom).setCodeItem("vbillno");
		((nc.bs.pubapp.pub.rule.UpdateBillCodeRule) ruleCom).setGroupItem("pk_group");
		((nc.bs.pubapp.pub.rule.UpdateBillCodeRule) ruleCom).setOrgItem("pk_org");
		processer.addBeforeRule(ruleCom);
		processer.addBeforeRule(new BeforeUpdateRule());
	}

}
